# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=futures
pkgbase=mingw-w64-python2-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-python2-${_realname}"
pkgver=3.3.0
pkgrel=1
pkgdesc="Backport of the concurrent.futures package from Python 3.2 (mingw-w64)"
arch=('any')
url='https://github.com/agronholm/pythonfutures'
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python2")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
options=('staticlibs' 'strip' '!debug')
source=("${_realname}-$pkgver.tar.gz"::"https://github.com/agronholm/pythonfutures/archive/$pkgver.tar.gz"
         LICENSE)
sha256sums=('0e2f48368adfa176311654ef85e9010b6ce785b407d5dc9d1f04d248bd18f87e'
            'd8e76be37a2af047bfa3852da422edc8c8fe08780039a280bf3f75b51e6c2835')

prepare() {
  cd "${srcdir}"
  rm -rf ${builddir} | true
  cp -r "python${_realname}-${pkgver}" "python2-build-${CARCH}"
  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
}

build() {
    msg "Python 2 build for ${CARCH}"  
    cd "${srcdir}/python2-build-${CARCH}"
    ${MINGW_PREFIX}/bin/python2 setup.py build
}

check() {
    msg "Python 2 test for ${CARCH}"
    cd "${srcdir}/python2-build-${CARCH}"
    ${MINGW_PREFIX}/bin/python2 setup.py test
}


package() {
  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

